package com.gifts.ui;

import java.io.InputStream;
import java.io.StringWriter;
import java.net.URL;
import java.net.URLConnection;
import java.util.Scanner;

import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.eclipse.swt.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.browser.*;
import org.eclipse.swt.custom.StackLayout;
import org.w3c.dom.events.EventTarget;

import com.gifts.service.FacebookService;
import com.gifts.ui.page.common.GiftMainPage;
import com.gifts.ui.page.common.Page;
import com.gifts.ui.page.common.PageFactory;
import com.gifts.ui.page.login.FacebookLoginPage;
import com.gifts.ui.page.selectafriend.SelectAFriendsPage;
/**
 * Main Driver class for GiftAFriend App
 * @author dmaung
 *
 */
public class GiftsMain {

	private FacebookService facebookService;
	private Page facebookLoginPage;
	private SelectAFriendsPage selectAFriendsPage;

	public GiftsMain() {
		this.facebookService = new FacebookService();
	}

	public static void main(String[] args) {
		Display display = new Display();
		final Shell shell = new Shell(display,SWT.CLOSE| SWT.TITLE);
		RowLayout rowLayout = new RowLayout();
		shell.setLayout(rowLayout);
		shell.setLayoutData( new RowData(800,100));
		shell.setLayout(new FillLayout());
		
		final Browser browser;
		try {

			String url = "https://www.facebook.com/dialog/oauth?client_id=265958666770031&redirect_uri=https://www.facebook.com/connect/login_success.html";
			// browser = new Browser(shell, SWT.EMBEDDED);

			// browser.setUrl(url);

		} catch (SWTError e) {
			System.out.println("Could not instantiate Browser: "
					+ e.getMessage());
			display.dispose();
			return;
		}

	
		// browser.setLayoutData(data);
		shell.setText("Facebook Gift A Friend");
		new GiftMainPage(shell, SWT.NONE);
		shell.open();
		shell.setSize(820, 720);
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		display.dispose();
		
	}
}